package ace.j2se.l2;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class WebScan {
	public static void main(String[] args) {
		List<String> linkList = new ArrayList<String>();

		try {
			URL url = new URL("http://www.verycd.com/topics/2917537/");
			BufferedReader br = new BufferedReader(new InputStreamReader(
					url.openStream()));
			String str = "";
			System.out.println("ed2k=\"".length() - 1);
			while ((str = br.readLine()) != null) {
				if (str.indexOf("ed2k=") != -1) {
					linkList.add(str.substring(
							str.indexOf("=\"") + "=\"".length(),
							str.indexOf("\">")));
				}
			}
			br.close();
		} catch (Exception e) {
			System.out.println("");
		}
		List<String> resultList = new ArrayList<String>();
		for (int i = 0; i < linkList.size(); i++) {
			String link = linkList.get(i);
			boolean isSaved = false;
			if (resultList.size() > 0) {
				for (int j = 0; j < resultList.size(); j++) {
					if (link.equalsIgnoreCase(resultList.get(j))) {
						isSaved = true;
						break;
					}
				}
			}
			if (!isSaved) {
				resultList.add(link);
			}
		}

		for (int i = 0; i < resultList.size(); i++) {
			System.out.println(resultList.get(i));
		}

	}
}
